<?php

/**
 * connect database with post table
 *
 * @author tham
 */
class Post {
    /*
     * Get al post with post_type = 'type_slider'
     * @author:tham
     * @return : $ds
     */

    public static function AllPostSliderTop() {
        global $wpdb;
        $sql = "Select *  "
                  . "from travel_posts  "
                  . "WHERE post_type = 'type_slider' AND post_status = 'publish'";
        $ds = $wpdb->get_results($sql);
        return $ds;
    }

    /*
      Get Img Url by ID Post
      @param  $ID
      @return $link_return
     */

    public static function get_thumbbyIDPpost($ID) {
        global $post, $wpdb;
        $thumb_ID = get_post_thumbnail_id($ID);
        $dsthumb_ID = get_post($thumb_ID);
        $link = $dsthumb_ID->guid;
        $dslink = explode('wp-content', $link);
        //print_r($dslink);
        $link_return = get_site_url() . '/wp-content' . $dslink[1];
        if (count($dslink) > 1) {
            return $link_return;
        } else {
            $link_return = "";
            return $link_return;
        }
    }

}
